import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 东莞呵呵
 * Date:2022-04-24
 * Time:10:31
 */
public class TestDemo5 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int max = 0;
        for (int i = 1; i < a; i++) {
            if (a % i == 0 && b % i == 0) {
                max = i;
            }
        }
        System.out.println(max);
    }

}
